<%-- 
    Document   : login
    Created on : 6-mar-2014, 23.22.53
    Author     : Fede
--%>

        
        <link href="CSS/stylelogin.css" rel="stylesheet" type="text/css" />        
        <script type="text/javascript">
        $(document).ready(function() {
                $('a.login-window').click(function() {

                        // Getting the variable's value from a link 
                        var loginBox = $(this).attr('href');

                        //Fade in the Popup and add close button
                        $(loginBox).fadeIn(300);

                        //Set the center alignment padding + border
                        var popMargTop = ($(loginBox).height() + 24) / 2; 
                        var popMargLeft = ($(loginBox).width() + 24) / 2; 

                        $(loginBox).css({ 
                                'margin-top' : -popMargTop,
                                'margin-left' : -popMargLeft
                        });

                        // Add the mask to body
                        $('body').append('<div id="mask"></div>');
                        $('#mask').fadeIn(300);

                        return false;
                });

                // When clicking on the button close or the mask layer the popup closed
                $('a.close, #mask').live('click', function() { 
                  $('#mask , .login-popup').fadeOut(300 , function() {
                        $('#mask').remove();  
                }); 
                return false;
                });
        });
        function imgChange2( img ) { document.login.src = img; } 
        </script>
  
         <%     
        session = request.getSession();
        String user = (String) session.getAttribute("nomeUtente");
        Integer flag = (Integer) session.getAttribute("flag");
        if(user==null){
        %>
            <div class="box">
                <div class="log-box">
                    <a href="#login-box" class="login-window" style="color:white;"><u>Login</u> |</a>
                </div>
                <div class="reg-box">
                    <a class="reg-box" href="registrazione.jsp" style="color:white;"><u>Registrati</u></a>
                </div>
            </div>
            <div id="login-box" class="login-popup">
                <a href="#" class="close"><img src="Images/close_pop.png" class="btn_close" title="Close Window" alt="Close"/></a>
                <form name="Login" method="post" class="signin" action="GeneralController">
                    <fieldset class="textbox">
                        <label class="username">
                            <span>Nome Utente</span>
                            <input id="username" name="username" value="" type="text" autocomplete="on" placeholder="Username">
                        </label>
                        <label class="password">
                            <span>Password</span>
                            <input id="password" name="password" value="" type="password" placeholder="Password">
                        </label>
                        <button type="submit" class="submit button" name="submit" value="Login">Login</button>   
                        <a style="font-size: 10px;color: black;text-decoration: underline;" href="recuperapsw.jsp?op=rec">Recupera password</a>
                    </fieldset>
                </form>
            </div>
        <% } else{ %>
        <div class="box">             
                        <div id="menu">
                            <!-- Lista generale -->
                            <ul>
                                <li>
                                    <% 
                                        String user_cut = user;
                                        if(user.length() > 21){
                                            user_cut = user.substring(0, 19) + "...";
                                    }
                                    %>
                                    <a href="profilo.jsp" class="user"><%=user_cut%>&nbsp;<img src="Images/freccia.png" width="20px" height="15px"></a>
                                    <ul>
                                        <li>
                                           <a href = "/mfm-centro-sportivo-war/GeneralController?submit=Profilo"><img src="Images/profilo.ico" width="20px" height="20px">&nbsp;&nbsp;Profilo</a>
                                        </li>
                                        <li>
                                           <a href = "cambiaPassword.jsp"><img src="Images/chiavi.png" width="20px" height="20px">&nbsp;&nbsp;Cambia password</a>
                                        </li>
                                        <% if(flag==1){ %>
                                            <li>
                                                <a href = "amministrazione.jsp"><img src="Images/admin.png" width="20px" height="15px">&nbsp;&nbsp;Amministrazione</a>
                                            </li>
                                        <% } %>
                                        <li>
                                            <a href="/mfm-centro-sportivo-war/GeneralController?submit=Logout"><img id="lamp2" src="Images/btn_logout.png" width="20px" height="20px">&nbsp;&nbsp;Logout
                                            </a>
                                        </li>
                                    </ul>
                                </li>
                            </ul>
                        </div>
        </div>
        <%}%>
 
